
const IS_PROD = ['production'].includes(process.env.NODE_ENV)
const plugins = []
if (IS_PROD) {
  plugins.push('transform-remove-console')
}
plugins.push('@babel/plugin-proposal-optional-chaining')
plugins.push(['import', {
  'libraryName': 'ant-design-vue',
  'libraryDirectory': 'es',
  'style': true
}])
plugins.push(['component', {
  'libraryName': 'element-ui',
  'styleLibraryName': 'theme-chalk'
}])
plugins.push(['@babel/plugin-transform-runtime', {
  corejs: 3,
  useESModules: false
}])
plugins.push(["transform-remove-strict-mode"])
module.exports = {
  presets: [
    '@vue/app', [
      '@babel/preset-env',
      {
        'useBuiltIns': 'entry',
        'corejs': 3,
        'modules': 'auto', // 现在不能通过webpack来解析s6 module，需要使用babel来解析，所以要开启
        'targets': {
          'node': 'current' // 指定环境为当前node版本，减少解析不识别语法的范围
        }
      }
    ]
  ],
  plugins,
  env: {
    test: {
      plugins: ['require-context-hook']
    }
  }
}
